/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.util.List;

import com.google.code.morphia.dao.BasicDAO;
import com.google.code.morphia.query.Query;

import entity.Category;

import org.bson.types.ObjectId;

/**
 *
 * @author xuanhung2401
 */
public class CategoryModel extends BasicDAO<Category, ObjectId>{
    public CategoryModel() {
        super(DBConnection.getMongo(), DBConnection.getMorphia(), DBConnection.getDatabase());
        ds.ensureIndexes();
    }
    
    public Category findByAlias(String alias) {
        return ds.find(Category.class, "alias", alias).get();
    }
       
    public List<Category> all() {
		Query<Category> q = ds.createQuery(Category.class);		
		return q.asList();
	}
}